/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.express.service;

import java.util.Date;
import java.util.List;

import com.jeeplus.modules.ordersstore.entity.OrdersStore;
import com.jeeplus.modules.ordersstore.service.OrdersStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.express.entity.Express;
import com.jeeplus.modules.express.mapper.ExpressMapper;

/**
 * 发货信息Service
 * @author lxj
 * @version 2020-11-10
 */
@Service
@Transactional(readOnly = true)
public class ExpressService extends CrudService<ExpressMapper, Express> {

	@Autowired
	private OrdersStoreService ordersStoreService;


	public Express get(String id) {
		return super.get(id);
	}
	
	public List<Express> findList(Express express) {
		return super.findList(express);
	}
	
	public Page<Express> findPage(Page<Express> page, Express express) {
		return super.findPage(page, express);
	}
	
	@Transactional(readOnly = false)
	public void save(Express express) {
		super.save(express);
	}
	
	@Transactional(readOnly = false)
	public void delete(Express express) {
		super.delete(express);
	}
	@Transactional(readOnly = false)
	public void saveNew(Express express) {
		if (express.getIsNewRecord()){
			express.setTime(new Date());
		}
		save(express);
		String id = express.getOrdersstore().getId();
		OrdersStore ordersStore = ordersStoreService.get(id);
		if (ordersStore!=null){
			ordersStore.setOrdersStatus("3");
			ordersStoreService.save(ordersStore);
		}


	}
}